package com.zhaoxi.project.wms.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhaoxi.framework.aspectj.lang.annotation.Log;
import com.zhaoxi.framework.aspectj.lang.enums.BusinessType;
import com.zhaoxi.project.wms.domain.WmsProductStockCheck;
import com.zhaoxi.project.wms.service.impl.WmsProductStockCheckServiceImpl;
import com.zhaoxi.framework.web.BaseService;
import com.zhaoxi.framework.web.PageData;
import com.zhaoxi.common.utils.poi.ExcelUtil;
import com.zhaoxi.framework.web.page.TableDataInfo;

/**
 * 仓储盘点Controller
 *
 * @author zhaoxi
 * @date 2023-08-25
 */
@RestController
@RequestMapping("/wms/stockCheck")
public class WmsProductStockCheckController extends BaseService {
    @Autowired
    private WmsProductStockCheckServiceImpl wmsProductStockCheckService;

    /**
     * 查询仓储盘点列表
     */
    @PreAuthorize("@ss.hasPermi('wms:stockCheck:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsProductStockCheck wmsProductStockCheck) {
        startPage();
        List<WmsProductStockCheck> list = wmsProductStockCheckService.selectWmsProductStockCheckList(wmsProductStockCheck);
        return getDataTable(list);
    }

    /**
     * 导出仓储盘点列表
     */
    @PreAuthorize("@ss.hasPermi('wms:stockCheck:export')")
    @Log(title = "仓储盘点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsProductStockCheck wmsProductStockCheck) {
        List<WmsProductStockCheck> list = wmsProductStockCheckService.selectWmsProductStockCheckList(wmsProductStockCheck);
        ExcelUtil<WmsProductStockCheck> util = new ExcelUtil<WmsProductStockCheck>(WmsProductStockCheck.class);
        util.exportExcel(response, list, "仓储盘点数据");
    }

    /**
     * 获取仓储盘点详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:stockCheck:query')")
    @GetMapping(value = "/{id}")
    public PageData getInfo(@PathVariable("id") Long id) {
        return success(wmsProductStockCheckService.selectWmsProductStockCheckById(id));
    }

    /**
     * 新增仓储盘点
     */
    @PreAuthorize("@ss.hasPermi('wms:stockCheck:add')")
    @Log(title = "仓储盘点", businessType = BusinessType.INSERT)
    @PostMapping
    public PageData add(@RequestBody WmsProductStockCheck wmsProductStockCheck) {
        return toAjax(wmsProductStockCheckService.insertWmsProductStockCheck(wmsProductStockCheck));
    }

    /**
     * 修改仓储盘点
     */
    @PreAuthorize("@ss.hasPermi('wms:stockCheck:edit')")
    @Log(title = "仓储盘点", businessType = BusinessType.UPDATE)
    @PutMapping
    public PageData edit(@RequestBody WmsProductStockCheck wmsProductStockCheck) {
        return toAjax(wmsProductStockCheckService.updateWmsProductStockCheck(wmsProductStockCheck));
    }

    /**
     * 删除仓储盘点
     */
    @PreAuthorize("@ss.hasPermi('wms:stockCheck:remove')")
    @Log(title = "仓储盘点", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public PageData remove(@PathVariable Long[] ids) {
        return toAjax(wmsProductStockCheckService.deleteWmsProductStockCheckByIds(ids));
    }
}
